<?php

/* ................................................................
  [七行 PHPCMS]
  .  VERSION: 1.0
  .  Author: SevenEl sevenelement@qq.com
  .  Support: http://www.sevenel.cn
  ................................................................ */
/* class configs
 * */

class EXT {

    const VERSION = 1.0;

    static $site_config = +1;

    static function GB($name) {
        global $fdada;
        global $plugurl;
        global $plugjs;
        global $fckplugin;
        global $listcf;
        static $nm = 0;
        $nm = $nm + 1;
        $back = is_odd($nm) ? "itemCls:'hang'," : "";
        $_REQUEST['lg'] != '' && $condition = " and lg like '" . $_REQUEST['lg'] . "' ";
        $fld = Dgd(array(
            'db' => 'd_sevenel',
            'cd' => " tid = '" . $_GET['tid'] . "' and fname ='" . $name . "' " . $condition . " ",
            'tn' => "fld",
            'limit' => 1
                ));
        if ($fld['cfg'] != '') {
            $config = json_decode($fld['cfg'], true);
        } else {
            $config = '';
        }
        $config['STR'] = str_replace("\r", "", $config['STR']);
        $config['STR'] = str_replace("\n", "", $config['STR']);
        $config['STR'] = str_replace("\t", "", $config['STR']);
        if ($listcf['editdisble'] != '' && $_GET['id']) {
            if (in_array($fld['fname'], $listcf['editdisble'])) {
                switch ($fld['type']) {
                    case 'htmleditor':
                    case 'fckeditor':
                    case 'kindeditor': {
                            $fld['type'] = 'lable';
                            break;
                        }
                    case 'fileup': {
                            $fld['type'] = 'fileup1';
                            break;
                        }
                    default : {
                            $config['STR'].="disabled:'true',";
                            break;
                        }
                }
            }
        };
        if ($listcf['zdgx'] != '' && $_GET['id']) {
            if (in_array($fld['fname'], $listcf['zdgx'])) {
                $fld['type'] = 'zdgx';
            }
        };
        switch ($fld['type']) {

            case 'hidden': {
                    $temp = "{
								xtype: 'hidden',
									value:\"" . (grv($fld['qzfs'], $fld['blm'], adxx($fdada[$fld['fname']]))) . "\",
									" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								name: '" . $fld['fname'] . "'
								}";
                    break;
                }
            case 'textfield': {
                    $temp = "{
								xtype: 'textfield',
								value:\"" . (grv($fld['qzfs'], $fld['blm'], adxx($fdada[$fld['fname']]))) . "\",
								fieldLabel:'" . $fld['name'] . "',
								" . (($fld['id']) ? ("id:'" . $fld['id'] . "',") : ("")) . "
								" . (($fld['width']) ? ("width:'" . $fld['width'] . "px',") : ("grow:true,growMin:68,growMax:300,")) . "
								" . ((!$fld['yxwk']) ? ("allowBlank:false,blankText:'" . adxx($fld['ts']) . "',") : ("")) . "
								" . (($config['readonly']) ? ("readOnly:'true',") : ("")) . "
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								" . $back . "
								name: '" . $fld['fname'] . "'
								}";
                    $plugurl[] = '/Plug-in/ext/adv-vtypes.js';

                    break;
                }
            case 'password': {
                    if ($_GET['id'] == '') {
                        $temp = "{
								xtype: 'textfield',
								value:\"" . (grv($fld['qzfs'], $fld['blm'], adxx($fdada[$fld['fname']]))) . "\",
								fieldLabel:'" . $fld['name'] . "',
								inputType: 'password',allowBlank:false,blankText:'密码不能为空',
								id: '" . $fld['fname'] . "',
								" . (($fld['width']) ? ("width:'" . $fld['width'] . "px',") : ("width:'100px',")) . "
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								" . $back . "name: '" . $fld['fname'] . "'
								},{
								xtype: 'textfield',
								value:\"" . (grv($fld['qzfs'], $fld['blm'], adxx($fdada[$fld['fname']]))) . "\",
								fieldLabel:'确认" . $fld['name'] . "',
								inputType: 'password',allowBlank:false,blankText:'密码不能为空',
								vtype: 'password',
								" . (($fld['width']) ? ("width:'" . $fld['width'] . "px',") : ("width:'100px',")) . "
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								initialPassField: '" . $fld['fname'] . "',
								" . $back . "name: '" . $fld['fname'] . "-cfrm'
								}";
                        $plugurl[] = '/Plug-in/ext/adv-vtypes.js';
                    } else {
                        $temp = "{
								xtype: 'button',
								text:'点击此处进行密码修改',
								handler:function(){
									var pr=top.Ext.get('fname" . $_GET['tid'] . $fld['fname'] . $_GET['id'] . "');
															if(pr){
																pr.close();
																}
															top.xajax_loadUrl('更新" . $fld['name'] . "','./zdgx/show.php?&op=show&tid=" . $_GET['tid'] . "&fname=" . $fld['fname'] . "&id=" . $_GET['id'] . "','438','138',false,'fname" . $_GET['tid'] . $fld['fname'] . $_GET['id'] . "');								}					}";
                    } break;
                }
            case 'fileup': {
                    if ($fdada[$fld['fname']] == '') {
                        $fdada[$fld['fname']] = 'zwtp.jpg';
                    }
                    $dvalue = array(0 => array('rar', 'zip', 'tar', '.tz'),
                        1 => array('jpg', 'gif', 'png', 'bmp'),
                        2 => array('mp3', 'mp4', 'avi', 'wmv', 'mid', '.rm', 'mvb', 'mov', 'wma', 'wav'),
                        3 => array('doc', 'xls', 'txt', 'ocx', 'lsx', 'ppt', 'pdf', 'chm'),
                        4 => array('doc', 'xls', 'txt', 'ocx', 'lsx', 'ppt', 'pdf', 'chm', 'mp3', 'mp4', 'avi', 'wmv', 'mid', '.rm', 'mvb', 'mov', 'wma', 'wav', 'jpg', 'gif', 'png', 'bmp', 'rar', 'zip', 'tar', '.tz')
                    );
                    $otype = substr(strtolower($fdada[$fld['fname']]), -3);
                    if (in_array($otype, $dvalue[0])) {
                        $zs = "<a href=\"/uplods/pic/" . $fdada[$fld['fname']] . "\" target=\'_blank\'><img src=\"../img/archive.png\">下载[Download]</a>";
                    }
                    //默认路径
                    $config['sclj'] || $config['sclj'] = 'pic';
                    if (in_array($otype, $dvalue[1])) {
                        if ($config['sypic'] == 1 || $config['sytxt'] == 1) {
                            $zs = "<img src=\"/uplods/sytp/" . substr($fdada[$fld['fname']], 0, -3) . "jpg\" >";
                        } else {
                            $zs = "<img src=\"/uplods/{$config['sclj']}/" . $fdada[$fld['fname']] . "\" >";
                        }
                    }
                    if (in_array($otype, $dvalue[2])) {
                        $zs = "<a href=\"/uplods/{$config['sclj']}/" . $fdada[$fld['fname']] . "\" target=\'_blank\'><img src=\"../img/film_link.png\">下载[Download]</a>";
                    }
                    if (in_array($otype, $dvalue[3])) {
                        $zs = "<a href=\"/uplods/{$config['sclj']}/" . $fdada[$fld['fname']] . "\" target=\'_blank\'><img src=\"../img/report_word.png\">下载[Download]</a>";
                    }
                    $qk = " <a href=\"#\"  onclick=qkzd(\"" . $fdada['id'] . "\",\"" . $fld['fname'] . "\") ><img src=\"../img/001_02.gif\">清空此附件</a>";
                    $temp = "{
								xtype: 'textfield',
								fieldLabel:'" . $fld['name'] . "',
								inputType: 'file',
								" . (($fld['id']) ? ("id:'" . $fld['id'] . "',") : ("")) . "
								width:'150',
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								" . $back . "name: '" . $fld['fname'] . "'
								},{" . $back . "html:'<div style=\"float:left;width:300px;\" align=center>" . $zs . "" . $qk . "</div>'}";
                    break;
                }
            case 'fileup1': {
                    if ($fdada[$fld['fname']] == '') {
                        $fdada[$fld['fname']] = 'zwtp.jpg';
                    }
                    $dvalue = array(0 => array('rar', 'zip', 'tar', '.tz'),
                        1 => array('jpg', 'gif', 'png', 'bmp'),
                        2 => array('mp3', 'mp4', 'avi', 'wmv', 'mid', '.rm', 'mvb', 'mov', 'wma', 'wav'),
                        3 => array('doc', 'xls', 'txt', 'ocx', 'lsx', 'ppt', 'pdf', 'chm'),
                        4 => array('doc', 'xls', 'txt', 'ocx', 'lsx', 'ppt', 'pdf', 'chm', 'mp3', 'mp4', 'avi', 'wmv', 'mid', '.rm', 'mvb', 'mov', 'wma', 'wav', 'jpg', 'gif', 'png', 'bmp', 'rar', 'zip', 'tar', '.tz')
                    );
                    $otype = substr(strtolower($fdada[$fld['fname']]), -3);
                    if (in_array($otype, $dvalue[0])) {
                        $zs = "<a href=\"/uplods/pic/" . $fdada[$fld['fname']] . "\" target=\'_blank\'><img src=\"../img/archive.png\">下载[Download]</a>";
                    }
                    if (in_array($otype, $dvalue[1])) {
                        if ($config['sypic'] == 1 || $config['sytxt'] == 1) {
                            $zs = "<img src=\"/uplods/sytp/" . $fdada[$fld['fname']] . "\" >";
                        } else {
                            $zs = "<img src=\"/uplods/pic/" . $fdada[$fld['fname']] . "\" >";
                        }
                    }
                    if (in_array($otype, $dvalue[2])) {
                        $zs = "<a href=\"/uplods/pic/" . $fdada[$fld['fname']] . "\" target=\'_blank\'><img src=\"../img/film_link.png\">下载[Download]</a>";
                    }
                    if (in_array($otype, $dvalue[3])) {
                        $zs = "<a href=\"/uplods/pic/" . $fdada[$fld['fname']] . "\" target=\'_blank\'><img src=\"../img/report_word.png\">下载[Download]</a>";
                    }

                    $temp = "{" . $back . "html:'<div style=\"float:left;width:300px;\" align=center>" . $zs . "" . $qk . "</div>'}";
                    break;
                }
            case 'textarea': {
                    $temp = preg_replace("/[\s]{2,}/", "", "{
								xtype: 'textarea',
								value:\"" . (grv($fld['qzfs'], $fld['blm'], adxx($fdada[$fld['fname']]))) . "\",
								fieldLabel:'" . $fld['name'] . "',
								grow:true,
								" . (($fld['id']) ? ("id:'" . $fld['id'] . "',") : ("")) . "
								" . (($fld['width']) ? ("width:'" . $fld['width'] . "px',") : ("width:'400px',")) . "
								" . ((!$fld['yxwk']) ? ("allowBlank:false,blankText:'" . adxx($fld['ts']) . "',") : ("")) . "
								" . (($config['readonly']) ? ("readOnly:'true',") : ("")) . "
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								" . $back . "
								name: '" . $fld['fname'] . "'
								}");
                    break;
                }
            case 'htmleditor': {
                    $temp = preg_replace("/[\s]{2,}/", "", "{
								xtype: 'htmleditor',
								value:\"" . (grv($fld['qzfs'], $fld['blm'], adxx($fdada[$fld['fname']]))) . "\",
								fieldLabel:'" . $fld['name'] . "',
								" . (($fld['id']) ? ("id:'" . $fld['id'] . "',") : ("")) . "
								" . (($fld['width']) ? ("width:" . $fld['width'] . ",") : ("anchor:'98%',")) . "
								" . (($config['height']) ? ("height:" . $config['height'] . ",") : ("")) . "
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								" . $back . "
								name: '" . $fld['fname'] . "'
								}");
                    break;
                }
            case 'lable': {
                    $temp = preg_replace("/[\s]{2,}/", "", "{
								html:\"<B><font color=#6c0a0f>" . $fld['name'] . "</font></B>&nbsp;&nbsp;" . (grv($fld['qzfs'], $fld['blm'], adxx($fdada[$fld['fname']]))) . "\"
								}");
                    break;
                }
            case 'fckeditor': {
                    $temp = preg_replace("/[\s]{2,}/", "", "{
							xtype:\"textarea\",
							" . (($fld['id']) ? ("id:'" . $fld['id'] . "',") : ("")) . "
							value:\"" . (grv($fld['qzfs'], $fld['blm'], adxx($fdada[$fld['fname']]))) . "\",
							" . (($fld['width']) ? ("width:" . $fld['width'] . ",") : ("anchor:'98%',")) . "
							" . (($config['height']) ? ("height:" . $config['height'] . ",") : ("height:300,")) . "
							fieldLabel:'" . $fld['name'] . "',
							" . $back . "
							listeners:{
								 focus:function(f){
													var myMask = new Ext.LoadMask(Ext.getBody(), {msg:'请等待'});
													myMask.show();
													var w=f.getSize();
													   fckEditor = new FCKeditor('" . $fld['fname'] . "') ;
													   fckEditor.Height=" . (($config['height']) ? ($config['height']) : (300)) . ";
													   fckEditor.Width=" . (($fld['width']) ? ($fld['width']) : (800)) . ";
													fckEditor.SkinPath = '/Plug-in/fck/editor/skins/silver/' ;
													fckEditor.BasePath = '/Plug-in/fck/' ;
													fckEditor.Config['ToolbarStartExpanded'] = " . (($config['zhed']) ? ("false") : ('true')) . ";
													" . (($config['STR']) ? ($config['STR']) : ("")) . "
													fckEditor.ReplaceTextarea() ;
													myMask.hide();
												 }
											   },
							name: '" . $fld['fname'] . "'
							}");
                    $fckplugin.="try{var fckobj_temp = FCKeditorAPI.GetInstance('" . $fld['fname'] . "');
											 fckobj_temp.UpdateLinkedField();}catch(err){
															};";
                    $plugurl[] = '/Plug-in/fck/fckeditor.js';   // fckEditor.ReplaceTextarea() ;
                    break;
                }
            case 'kindeditor': {
                    $yuan = array("</script>", "vegetables", "fiber");
                    $tyuan = array("<\/script>", "beer", "ice cream");

                    $temp = preg_replace("/[\s]{2,}/", "", "{
							xtype:\"textarea\",
							id:'" . $fld['fname'] . "',
							" . $back . "
							value:\"" . (grv($fld['qzfs'], $fld['blm'], str_replace($yuan, $tyuan, adxx(preg_replace("'([\r\n])[\s]+'", "", $fdada[$fld['fname']]))))) . "\",
							" . (($fld['width']) ? ("width:" . $fld['width'] . ",") : ("anchor:'98%',")) . "
							" . (($config['height']) ? ("height:" . $config['height'] . ",") : ("height:300,")) . "
							fieldLabel:'" . $fld['name'] . "',
                            listeners:{
                                   render:function(f){
                                                        try{
                                                            KEeditor{$fld['fname']}='';
                                                            KindEditor.ready(function(K) {
                                                                    KEeditor{$fld['fname']} = K.create('#{$fld['fname']}', {
                                                                            resizeType : 2,
                                                                            " . (($config['STR']) ? ($config['STR']) : ("")) . "
                                                                            width:" . (($fld['width']) ? ("'" . $fld['width'] . "px'") : ('70%')) . ",
                                                                            height:" . (($config['height']) ? ("'" . $config['height'] . "px'") : ("'300px'")) . "
                                                                    });
                                                            });
                                                        }catch(err){
                                                                };
                                                        }
                                               },

                            name: '" . $fld['fname'] . "'
                            }");
                    $fckplugin.="KEeditor{$fld['fname']}.sync();";
                    $plugurl[] = '/Plug-in/kind/kindeditor.js';   // fckEditor.ReplaceTextarea() ;
                    break;
                }
            case 'datefield': {
                    if (is_numeric($fdada[$fld['fname']])) {
                        $fdada[$fld['fname']] = date($config['zqgs'], $fdada[$fld['fname']]);
                    }
                    $temp = "{
								xtype: 'datefield',
								" . $back . "
								value:\"" . (grv($fld['qzfs'], $fld['blm'], adxx($fdada[$fld['fname']]))) . "\",
								fieldLabel:'" . $fld['name'] . "',
								" . (($fld['id']) ? ("id:'" . $fld['id'] . "',") : ("")) . "
								" . (($fld['width']) ? ("width:" . $fld['width'] . ",") : ("")) . "
								disabledDays :[" . @implode(',', $config['pbxq']) . "],
								" . ((!$fld['yxwk']) ? ("allowBlank:false,blankText:'" . adxx($fld['ts']) . "',") : ("")) . "
								" . (($config['zwxs']) ? ("readOnly:'true',") : ("")) . "
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								" . (($config['zqgs']) ? ("format:'" . $config['zqgs'] . "',") : ("")) . "
								name: '" . $fld['fname'] . "'
								}";
                    if ($config['zwxs'] == 1) {
                        $plugjs[] = 'Date.dayNames = ["日", "一", "二", "三", "四", "五", "六"];
								if (Ext.DatePicker) {
									Ext.apply(Ext.DatePicker.prototype, {
										todayText: "今天",
										minText: "日期在最小日期之前",
										maxText: "日期在最大日期之后",
										disabledDaysText: "",
										disabledDatesText: "",
										monthNames: Date.monthNames,
										dayNames: Date.dayNames,
										nextText: "下月 (Control+Right)",
										prevText: "上月 (Control+Left)",
										monthYearText: "选择一个月 (Control+Up/Down 来改变年)",
										todayTip: "{0} (Spacebar)",
										okText: "确定",
										cancelText: "取消",
										format: "y年m月d日"
									});
						}';
                    }
                    break;
                }
            case 'my97': {
                    if (is_numeric($fdada[$fld['fname']])) {
                        $fdada[$fld['fname']] = date($config['zqgs'], $fdada[$fld['fname']]);
                    }
                    $temp = "{
								xtype: 'textfield',
								" . $back . "
								value:\"" . (grv($fld['qzfs'], $fld['blm'], adxx($fdada[$fld['fname']]))) . "\",
                                cls:'Wdate',
								fieldLabel:'" . $fld['name'] . "',
								" . (($fld['id']) ? ("id:'" . $fld['id'] . "',") : ("")) . "
								" . (($fld['width']) ? ("width:" . $fld['width'] . ",") : ("")) . "
								disabledDays :[" . @implode(',', $config['pbxq']) . "],
								" . ((!$fld['yxwk']) ? ("allowBlank:false,blankText:'" . adxx($fld['ts']) . "',") : ("")) . "
								" . (($config['zwxs']) ? ("readOnly:'true',") : ("")) . "
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								" . (($config['zqgs']) ? ("format:'" . $config['zqgs'] . "',") : ("")) . "
								name: '" . $fld['fname'] . "',
                                listeners:{
                                    focus:function(){
                                        WdatePicker({dateFmt:'{$config['mygs']}'})
                                    }
                                }
								}";
                    break;
                }
            case 'swfupload': {
                    $temp = "{
								xtype: '{$fld['type']}',
								" . $back . "
								name: '{$fld['fname']}',
								id: '{$fld['fname']}',
								fieldLabel: '{$fld['name']}',
								anchor:'99%',
								height: {$config['height']}
							}";
                    break;
                }
            case 'combo': {
                    $tempxx = json_decode($fld['zyz'], true);
                    $config_num = count($tempxx);
                    $items = '';
                    if ($config_num != 0) {
                        foreach ($tempxx as $key => $data) {
                            if ($data['ck'] == '1') {
                                $fdada[$fld['fname']] ? $fdada[$fld['fname']] : $fdada[$fld['fname']] = $data['xv'];
                            }
                            $items.= "['" . $data['xv'] . "','" . $data['yv'] . "']";
                            if ($key < $config_num - 1) {
                                $items.= ",";
                            }
                        }
                    }
                    $temp = "{
								" . $back . "
								value:\"" . (grv($fld['qzfs'], $fld['blm'], adxx($fdada[$fld['fname']]))) . "\",
								fieldLabel:'" . $fld['name'] . "',
								" . (($fld['id']) ? ("id:'" . $fld['id'] . "',") : ("")) . "
								" . (($fld['width']) ? ("width:" . $fld['width'] . ",") : ("")) . "
								" . ((!$fld['yxwk']) ? ("allowBlank:false,blankText:'" . adxx($fld['ts']) . "',") : ("")) . "
								" . (($config['readonly']) ? ("readOnly:'true',") : ("")) . "
								typeAhead: true,
								name: '" . $fld['fname'] . "_',
								hiddenName : '" . $fld['fname'] . "',
								editable: false,xtype: 'combo',
								store:new Ext.data.SimpleStore({
												fields:['name','value'],
												data:[" . $items . "]}),
								mode:'local',
								displayField:'name',
								selectOnFocus:true,
								valueField :'value',
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								triggerAction:'all'

								}";
                    break;
                }
            case 'combo1': {
                    $temp = "{
								" . $back . "
								value:\"" . (adxx($fdada[$fld['fname']]) ? adxx($fdada[$fld['fname']]) : $config['dy']) . "\",
								fieldLabel:'" . $fld['name'] . "',
								" . (($fld['id']) ? ("id:'" . $fld['id'] . "',") : ("")) . "
								" . (($fld['width']) ? ("width:" . $fld['width'] . ",") : ("")) . "
								" . ((!$fld['yxwk']) ? ("allowBlank:false,blankText:'" . adxx($fld['ts']) . "',") : ("")) . "
								" . (($config['readonly']) ? ("readOnly:'true',") : ("")) . "
								typeAhead: true,
								emptyText:'" . $config['dx'] . "',
								name: '" . $fld['fname'] . "_',
								id: '" . $fld['fname'] . "_',
								hiddenName : '" . $fld['fname'] . "',
								editable: false,xtype: 'combo',
								store:new Ext.data.Store({
									proxy: new Ext.data.HttpProxy({
										url: '../cascade/getcascade.php?id=" . $fld['id'] . "&setCombo1=" . $listcf['setCombo1'][$config['table']] . "'
									}),
									listeners : {
									load : function(){

											if(typeof(chuzai" . $fld['fname'] . ")=='undefined'){
												Ext.getCmp('" . $fld['fname'] . "_" . "').setValue('" . (adxx($fdada[$fld['fname']]) ? adxx($fdada[$fld['fname']]) : $config['dy']) . "');
												chuzai" . $fld['fname'] . "=1;
												}
											}
											} ,
									autoLoad:true,
									reader: new Ext.data.ArrayReader({
								}, [
									{name: '" . $config['y'] . "', mapping: '" . $config['y'] . "'},
									{name: '" . $config['x'] . "', mapping: '" . $config['x'] . "'}
								])
	}),
								mode:'local',
								displayField:'" . $config['x'] . "',
								selectOnFocus:true,
								valueField :'" . $config['y'] . "',
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								triggerAction:'all'

								}";
                    //print_r ($config['table']);
                    break;
                }
            case 'radiogroup': {
                    $tempxx = json_decode($fld['zyz'], true);
                    $config_num = count($tempxx);
                    if ($config_num != 0) {
                        $items = '';
                        if ($_GET['id'] != '') {
                            foreach ($tempxx as $key => $data) {
                                if ($data['yv'] == $fdada[$fld['fname']]) {
                                    $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $fld['fname'] . "',inputValue:'" . $data['yv'] . "',checked: true}";
                                } else {
                                    $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $fld['fname'] . "',inputValue:'" . $data['yv'] . "'}";
                                }
                                if ($key < $config_num - 1) {
                                    $items.= ",";
                                }
                            }
                        } else {
                            foreach ($tempxx as $key => $data) {
                                if ($data['ck'] == '1') {
                                    $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $fld['fname'] . "',inputValue:'" . $data['yv'] . "',checked: true}";
                                } else {
                                    $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $fld['fname'] . "',inputValue:'" . $data['yv'] . "'}";
                                }
                                if ($key < $config_num - 1) {
                                    $items.= ",";
                                }
                            }
                        }
                    }
                    $temp = "{
								xtype: 'radiogroup',
								" . $back . "
								" . (($fld['width'] && $fld['width'] <= $config_num) ? ("columns:" . $fld['width'] . ",") : ("")) . "
								" . (($config['vertical']) ? ("vertical: true,") : ("")) . "
								" . ((!$fld['yxwk']) ? ("allowBlank:false,blankText:'" . adxx($fld['ts']) . "',") : ("")) . "
								anchor: '95%',
								 items: [" . $items . "],
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								fieldLabel:'" . $fld['name'] . "'
								}";
                    break;
                }
            case 'recommend': {
                    $items = '';
                    $bs0 = '不推荐';
                    $bs1 = '推荐中';
                    if ($config['bs0'] != '' && $config['bs1'] != '') {
                        $bs0 = $config['bs0'];
                        $bs1 = $config['bs1'];
                    }
                    if ($fdada[$fld['fname']] > 0) {
                        $items.= "{boxLabel:'{$bs1}',name:'" . $fld['fname'] . "',inputValue:'{$fdada[$fld['fname']]}',checked: true},";
                        $items.= "{boxLabel:'{$bs0}',name:'" . $fld['fname'] . "',inputValue:'0'}";
                    } else {
                        $recommend_val = $fdada[$fld['fname']] != '' && $fdada[$fld['fname']] != 0 ? $fdada[$fld['fname']] : 1;
                        if ($config['mr'] == 1 && !$_GET['id']) {
                            $items.= "{boxLabel:'{$bs1}',name:'" . $fld['fname'] . "',inputValue:'{$recommend_val}',checked: true},";
                            $items.= "{boxLabel:'{$bs0}',name:'" . $fld['fname'] . "',inputValue:'0'}";
                        } else {
                            $items.= "{boxLabel:'{$bs1}',name:'" . $fld['fname'] . "',inputValue:'{$recommend_val}'},";
                            $items.= "{boxLabel:'{$bs0}',name:'" . $fld['fname'] . "',inputValue:'0',checked: true}";
                        }
                    }

                    $temp = "{
								xtype: 'radiogroup',
								" . $back . "
								" . ((!$fld['yxwk']) ? ("allowBlank:false,blankText:'" . adxx($fld['ts']) . "',") : ("")) . "
								anchor: '95%',
								 items: [" . $items . "],
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								fieldLabel:'" . $fld['name'] . "'
								}";
                    break;
                }
            case 'checkboxgroup': {
                    $tempxx = json_decode($fld['zyz'], true);
                    $config_num = count($tempxx);
                    if ($config_num != 0) {
                        $items = '';
                        if ($_GET['id'] != '') {
                            $xsarray = explode("#_#", $fdada[$fld['fname']]);
                            foreach ($tempxx as $key => $data) {
                                if (in_array($data['yv'], $xsarray)) {
                                    $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $fld['fname'] . "[" . $key . "]',inputValue:'" . $data['yv'] . "',checked: true}";
                                } else {
                                    $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $fld['fname'] . "[" . $key . "]',inputValue:'" . $data['yv'] . "'}";
                                }
                                if ($key < $config_num - 1) {
                                    $items.= ",";
                                }
                            }
                        } else {
                            foreach ($tempxx as $key => $data) {
                                if ($data['ck'] == '1') {
                                    $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $fld['fname'] . "[" . $key . "]',inputValue:'" . $data['yv'] . "',checked: true}";
                                } else {
                                    $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $fld['fname'] . "[" . $key . "]',inputValue:'" . $data['yv'] . "'}";
                                }
                                if ($key < $config_num - 1) {
                                    $items.= ",";
                                }
                            }
                        }
                    }
                    $temp = "{
								xtype:'checkboxgroup',
								" . $back . "
								" . (($fld['width'] && $fld['width'] <= $config_num) ? ("columns:" . $fld['width'] . ",") : ("")) . "
								" . (($config['vertical']) ? ("vertical: true,") : ("")) . "
								" . ((!$fld['yxwk']) ? ("allowBlank:false,blankText:'" . adxx($fld['ts']) . "',") : ("")) . "
								anchor: '95%',
								 items: [" . $items . "],
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								fieldLabel:'" . $fld['name'] . "'
								}";
                    break;
                }
            case 'checkboxgroup1': {
                    $tempxx = Dgs("{$config['table']}", "{$config['conditon']}");
                    $config_num = count($tempxx);
                    if ($config_num != 0) {
                        $items = '';
                        if ($_GET['id'] != '') {
                            $xsarray = explode("#_#", $fdada[$fld['fname']]);
                            foreach ($tempxx as $key => $data) {
                                if (in_array($data[$config['y']], $xsarray)) {
                                    $items.= "{boxLabel:'" . $data[$config['x']] . "',name:'" . $fld['fname'] . "[" . $key . "]',inputValue:'" . $data[$config['y']] . "',checked: true}";
                                } else {
                                    $items.= "{boxLabel:'" . $data[$config['x']] . "',name:'" . $fld['fname'] . "[" . $key . "]',inputValue:'" . $data[$config['y']] . "'}";
                                }
                                if ($key < $config_num - 1) {
                                    $items.= ",";
                                }
                            }
                        } else {    //添加的时候
                            foreach ($tempxx as $key => $data) {
                                $items.= "{boxLabel:'" . $data[$config['x']] . "',name:'" . $fld['fname'] . "[" . $key . "]',inputValue:'" . $data[$config['y']] . "'}";
                                if ($key < $config_num - 1) {
                                    $items.= ",";
                                }
                            }
                        }
                    }
                    $temp = "{
					xtype:'checkboxgroup',
					" . $back . "
					" . (($fld['width'] && $fld['width'] <= $config_num) ? ("columns:" . $fld['width'] . ",") : ("")) . "
					" . (($config['vertical']) ? ("vertical: true,") : ("")) . "
					" . ((!$fld['yxwk']) ? ("allowBlank:false,blankText:'" . adxx($fld['ts']) . "',") : ("")) . "
					anchor: '95%',
					items: [" . $items . "],
					" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
					fieldLabel:'" . $fld['name'] . "'
				}";
                    break;
                }
            case 'zdgx': {
                    $temp = preg_replace("/[\s]{2,}/", "", "{
								html:\"<B><font color=#6c0a0f>" . $fld['fname'] . "</font></B>&nbsp;&nbsp;" . (grv($fld['qzfs'], $fld['blm'], adxx($fdada[$fld['fname']]))) . "\"
								}");
                    if ((isset($_SESSION['rcg']['zdgxkey'][$_GET['tid']]) && $_SESSION['rcg']['zdgxkey'][$_GET['tid']] == 1) || $_SESSION['rcg'] == 'A') {
                        $temp.=",{
								xtype: 'button',
								text:'点击此处进行" . $fld['name'] . "修改',
								handler:function(){
									var pr=top.Ext.get('fname" . $_GET['tid'] . $fld['fname'] . $_GET['id'] . "');
															if(pr){
																pr.close();
																}
															top.xajax_loadUrl('更新" . $fld['name'] . "','./zdgx/show.php?&op=show&tid=" . $_GET['tid'] . "&fname=" . $fld['fname'] . "&id=" . $_GET['id'] . "','438','138',false,'fname" . $_GET['tid'] . $fld['fname'] . $_GET['id'] . "');								}					}";
                    }
                    break;
                }
            default: {
                    $temp = "{
								xtype: 'textfield',
								fieldLabel: '{$fld['name']}',
								name: '{$fld['fname']}',
								" . $back . "
								anchor:'60%'
							}";
                    break;
                }
        }
        return $temp;
    }

    static function GG($id) {
        global $ckbox;
        global $plugurl;
        global $plugjs;
        global $fckplugin;
        global $listcf;
        static $nm = 0;
        $nm = $nm + 1;
        $back = is_odd($nm) ? "itemCls:'hang'," : "";

        $fld = Dgd(array(
            'db' => 'd_sevenel',
            'cd' => " id = '" . $id . "'",
            'tn' => "fld",
            'limit' => 1
                ));
        if ($fld['cfg'] != '') {
            $config = json_decode($fld['cfg'], true);
        } else {
            $config = '';
        }
        $config['STR'] = str_replace("\r", "", $config['STR']);
        $config['STR'] = str_replace("\n", "", $config['STR']);
        $config['STR'] = str_replace("\t", "", $config['STR']);
        switch ($fld['type']) {
            case 'datefield': {
                    $temp = "{
							xtype: 'datefield',
							value:\"\",
							fieldLabel:'" . $fld['name'] . "',
							" . (($fld['id']) ? ("id:'" . $fld['id'] . "',") : ("")) . "
							" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
							" . (($config['zqgs']) ? ("format:'" . $config['zqgs'] . "',") : ("")) . "
							name: '" . $fld['fname'] . "'
							}";
                    break;
                }
            case 'combo': {
                    $tempxx = json_decode($fld['zyz'], true);
                    $config_num = count($tempxx);
                    $items = '';
                    if ($config_num != 0) {
                        foreach ($tempxx as $key => $data) {
                            if ($data['ck'] == '1') {
                                $xzz = $data['xv'];
                            }
                            $items.= "['" . $data['xv'] . "','" . $data['yv'] . "']";
                            if ($key < $config_num - 1) {
                                $items.= ",";
                            }
                        }
                    }
                    $temp = "{
								value:\"" . $xzz . "\",
								fieldLabel:'" . $fld['name'] . "',
								" . (($fld['id']) ? ("id:'" . $fld['id'] . "',") : ("")) . "
								" . (($fld['width']) ? ("width:" . $fld['width'] . ",") : ("")) . "
								" . (($config['readonly']) ? ("readOnly:'true',") : ("")) . "
								typeAhead: true,
								name: '" . $fld['fname'] . "_',
								hiddenName : '" . $fld['fname'] . "',
								editable: false,xtype: 'combo',
								store:new Ext.data.SimpleStore({
												fields:['name','value'],
												data:[" . $items . "]}),
								mode:'local',
								displayField:'name',
								selectOnFocus:true,
								valueField :'value',
								triggerAction:'all'

								}";
                    break;
                }
            case 'combo1': {

                    $temp = "{
								" . $back . "
								value:\"\",
								fieldLabel:'" . $fld['name'] . "',
								" . (($fld['id']) ? ("id:'" . $fld['id'] . "',") : ("")) . "
								" . (($fld['width']) ? ("width:" . $fld['width'] . ",") : ("")) . "
								" . ((!$fld['yxwk']) ? ("allowBlank:false,blankText:'" . adxx($fld['ts']) . "',") : ("")) . "
								" . (($config['readonly']) ? ("readOnly:'true',") : ("")) . "
								typeAhead: true,
								emptyText:'" . $config['dx'] . "',
								name: '" . $fld['fname'] . "_',
								id: '" . $fld['fname'] . "_',
								hiddenName : '" . $fld['fname'] . "',
								editable: false,xtype: 'combo',
								store:new Ext.data.Store({
									proxy: new Ext.data.HttpProxy({
										url: '../cascade/getcascade.php?id=" . $fld['id'] . "&setCombo1=" . $listcf['setCombo1'] . "'
									}),
									listeners : {
									load : function(){

											if(typeof(chuzai" . $fld['fname'] . ")=='undefined'){
												Ext.getCmp('" . $fld['fname'] . "_" . "').setValue('" . (adxx($fdada[$fld['fname']]) ? adxx($fdada[$fld['fname']]) : $config['dy']) . "');
												chuzai" . $fld['fname'] . "=1;
												}
											}
											} ,
									autoLoad:true,
									reader: new Ext.data.ArrayReader({
								}, [
									{name: '" . $config['y'] . "', mapping: '" . $config['y'] . "'},
									{name: '" . $config['x'] . "', mapping: '" . $config['x'] . "'}
								])
	}),
								mode:'local',
								displayField:'" . $config['x'] . "',
								selectOnFocus:true,
								valueField :'" . $config['y'] . "',
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								triggerAction:'all'

								}";
                    break;
                }
            case 'radiogroup': {
                    $tempxx = json_decode($fld['zyz'], true);
                    $config_num = count($tempxx);
                    if ($config_num != 0) {
                        $items = '';
                        foreach ($tempxx as $key => $data) {
                            if ($data['ck'] == '1') {
                                $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $fld['fname'] . "',inputValue:'" . $data['yv'] . "',checked: true}";
                            } else {
                                $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $fld['fname'] . "',inputValue:'" . $data['yv'] . "'}";
                            }
                            if ($key < $config_num - 1) {
                                $items.= ",";
                            }
                        }
                    }
                    $temp = "{
								xtype: 'radiogroup',
								" . (($fld['width'] && $fld['width'] <= $config_num) ? ("columns:" . $fld['width'] . ",") : ("")) . "
								" . (($config['vertical']) ? ("vertical: true,") : ("")) . "
								anchor: '95%',
								 items: [" . $items . "],
								fieldLabel:'" . $fld['name'] . "'
								}";
                    break;
                }
            case 'recommend': {
                    $items = '';
                    $items.= "{boxLabel:'推荐中',name:'" . $fld['fname'] . "',inputValue:'1'},";
                    $items.= "{boxLabel:'不推荐',name:'" . $fld['fname'] . "',inputValue:'0',checked: true}";

                    $temp = "{
								xtype: 'radiogroup',
								anchor: '95%',
								 items: [" . $items . "],
								fieldLabel:'" . $fld['name'] . "'
								}";
                    break;
                }
            case 'checkboxgroup': {
                    $tempxx = json_decode($fld['zyz'], true);
                    $config_num = count($tempxx);
                    if ($config_num != 0) {
                        $items = '';
                        foreach ($tempxx as $key => $data) {
                            $ckbox[] = $fld['fname'] . "[" . $key . "]";
                            if ($data['ck'] == '1') {
                                $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $fld['fname'] . "[" . $key . "]',inputValue:'" . $data['yv'] . "',checked: true}";
                            } else {
                                $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $fld['fname'] . "[" . $key . "]',inputValue:'" . $data['yv'] . "'}";
                            }
                            if ($key < $config_num - 1) {
                                $items.= ",";
                            }
                        }
                    }
                    $temp = "{
								xtype:'checkboxgroup',
								" . (($fld['width'] && $fld['width'] <= $config_num) ? ("columns:" . $fld['width'] . ",") : ("")) . "
								" . (($config['vertical']) ? ("vertical: true,") : ("")) . "
								anchor: '95%',
								 items: [" . $items . "],
								fieldLabel:'" . $fld['name'] . "'
								}";
                    break;
                }
            case 'checkboxgroup1': {
                    $tempxx = Dgs("{$config['table']}", "{$config['conditon']}");
                    $config_num = count($tempxx);
                    if ($config_num != 0) {
                        $items = '';
                        foreach ($tempxx as $key => $data) {
                            $ckbox[] = $fld['fname'] . "[" . $key . "]";
                            if ($data['ck'] == '1') {
                                $items.= "{boxLabel:'" . $data[$config['x']] . "',name:'" . $fld['fname'] . "[" . $key . "]',inputValue:'" . $data[$config['y']] . "',checked: true}";
                            } else {
                                $items.= "{boxLabel:'" . $data[$config['x']] . "',name:'" . $fld['fname'] . "[" . $key . "]',inputValue:'" . $data[$config['y']] . "'}";
                            }
                            if ($key < $config_num - 1) {
                                $items.= ",";
                            }
                        }
                    }
                    $temp = "{
					xtype:'checkboxgroup',
					" . (($fld['width'] && $fld['width'] <= $config_num) ? ("columns:" . $fld['width'] . ",") : ("")) . "
					" . (($config['vertical']) ? ("vertical: true,") : ("")) . "
					anchor: '95%',
					items: [" . $items . "],
					fieldLabel:'" . $fld['name'] . "'
				}";
                    break;
                }
            default: {
                    $temp = "{
								xtype: 'textfield',
								value:\"\",
								fieldLabel:'" . $fld['name'] . "',
								" . (($fld['id']) ? ("id:'" . $fld['id'] . "',") : ("")) . "
								" . (($fld['width']) ? ("width:'" . $fld['width'] . "px',") : ("grow:true,growMin:68,growMax:300,")) . "
								" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
								name: '" . $fld['fname'] . "'
								}";
                }
        }
        return $temp;
    }

}

?>
